package nowcoder.hw.hj33;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

//3868643487
public class Main1 {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String ipAddr = reader.readLine();
        String number = reader.readLine();
        System.out.println(convert10(ipAddr));
        System.out.println(convertIpAddr(number));

    }

    private static String convertIpAddr(String number) {
        Long val = Long.valueOf(number);

        return (val >> 24 & 255) + "."
                + (val >> 16 & 255) + "."
                + (val >> 8 & 255) + "."
                + (val & 255);
    }

    private static Long convert10(String ipAddr) {
        String[] strings = ipAddr.split("\\.");

        return Long.valueOf(strings[0]) << 24
                | Long.valueOf(strings[1]) << 16
                | Long.valueOf(strings[2]) << 8
                | Long.valueOf(strings[3]);
    }
}